package com.xjtu.mybatisplus.common.config;


//import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfig {

    //    @Bean
    //    public Docket api() {
    //        return new Docket(DocumentationType.SWAGGER_2)
    //                .select()
    //                .apis(RequestHandlerSelectors.basePackage("com/example/mybatisplus/web/controller")) // 替换为你的Controller所在的包名
    //                .paths(PathSelectors.any())
    //                .build()
    //                .apiInfo(apiInfo());
    //    }
    //
    //    private ApiInfo apiInfo() {
    //        return new ApiInfoBuilder()
    //                .title("我的")
    //                .description("Your API Description")
    //                .version("1.0")
    //                .build();
    //    }

    @Bean
    public Docket docket() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()).enable(true)
                .select()
                //apis： 添加swagger接口提取范围
                .apis(RequestHandlerSelectors.basePackage("com.xjtu.mybatisplus.web.controller"))
                .paths(PathSelectors.any())
                .build();
        System.out.println("docket加载成功");


        return docket;
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Intensification")
                .description("API Document")
                .version("v1.0")
                .build();
    }


}
